 {
        
 cc.Class({
            extends: cc.Component,
            properties: {
                bubble: cc.Node
            },
            onLoad: function () {
                Global.notificationCenter.on(Global.eventName.MSG_SHOW_NPC_BUBBLE, this.showNPCBubble.bind(this), this),
                    Global.notificationCenter.on(Global.eventName.MSG_HIDE_NPC_BUBBLE, this.hideNPCBubble.bind(this), this),
                    this._isGameStart = Global.tableModel.getIsGameStart();
            },
            start: function () {
                if (this.bubble) {
                    var e = Global.utils.searchComp(this.bubble, "labStr", cc.Label);
                    this.labOriginWid = e.node.width;
                }
                this.showInGameBubble();
            },
            onDestroy: function () {
                Global.notificationCenter.offAll(this), this.unscheduleAllCallbacks();
            },
            showInGameBubble: function () {
                if (this._isGameStart) {
                    this.showNPCBubble({
                        id: 1,
                        isTop: !0
                    }), this.schedule(function () {
                        this._isGameStart = Global.tableModel.getIsGameStart(), this._isGameStart || (this.unscheduleAllCallbacks(),
                            this.hideNPCBubble(), this.autoRandomChat());
                    }.bind(this), 2);
                } else this.scheduleOnce(function () {
                    this.autoRandomChat();
                }.bind(this), 4);
            },
            autoRandomChat: function () {
                if (this.npcBubbleConfig || (this.npcBubbleConfig = Global.configCdn.getNPCBubbleConf() || Global.configCdn.getDefaultConfig("npcBubble")),
                    !this.randomBubbleData) {
                    this.randomBubbleData = this._getTargetNPCBubbleConfigById(2);
                }
                var e = this.randomBubbleData && this.randomBubbleData.randomPercent || .9, t = Math.random() > e;
                if (console.log("autoRandomChat allowShow:", t, this.randomBubbleData), t) {
                    var n = this.randomBubbleData && this.randomBubbleData.randomId || [];
                    if (n && n.length > 0) {
                        var o = {
                            id: Global.utils.randomInt(n[0], n[n.length - 1])
                        };
                        this.showNPCBubble(o);
                    }
                } else this.scheduleOnce(this.autoRandomChat.bind(this), 6);
            },
            showNPCBubble: function (e) {
                if (e) if (this._isShowingTop) console.log("showNPCBubble _isShowingTop = ", this._isShowingTop); else {
                    var t = e.id || 2, n = e.isTop;
                    this._isShowingTop = !!n, this.npcBubbleConfig || (this.npcBubbleConfig = Global.configCdn.getNPCBubbleConf() || Global.configCdn.getDefaultConfig("npcBubble"));
                    var o = this._getTargetNPCBubbleConfigById(t);
                    o ? (console.info("showNPCBubble data:", o), this._showNPCBubbleByConfig(o)) : console.error("showNPCBubble error:", o, t);
                } else console.error("showNPCBubble error obj= ", e);
            },
            _getTargetNPCBubbleConfigById: function (e) {
                var t = {
                    id: 6,
                    type: 1,
                    action: "doQuickStart",
                    str: "没事就点我啦，打几局血流成河撒～～",
                    duration: 7,
                    spBtnName: "DT_queding",
                    playMode: "xueliu"
                };
                if (this.npcBubbleConfig && this.npcBubbleConfig.length > 0) for (var n = 0; n < this.npcBubbleConfig.length; n++) {
                    var o = this.npcBubbleConfig[n];
                    o.id == e && (t = o);
                }
                return t;
            },
            hideNPCBubble: function () {
                this.bubble && this.bubble.active && (this.bubble.active = !1, this.reset()), this._isGameStart || this.scheduleOnce(this.autoRandomChat.bind(this), Global.utils.randomInt(2, 4));
            },
            _showNPCBubbleByConfig: function (e) {
                if (e && this.bubble) {
                    var t = e.duration, n = e.str || "", o = e.action || "", i = e.spBtnName || "",
                        a = e.atlasName || "Texture/newHallUI", r = e.randomChat, s = e.playMode, l = e.needFiger;
                    console.log("_showNPCBubbleByConfig data:", e);
                    var c = Global.utils.searchComp(this.bubble, "labStr", cc.Label),
                        d = Global.utils.searchComp(this.bubble, "spBtn", cc.Sprite),
                        u = Global.utils.searchNode(this.bubble, "figer");
                    if (u && (u.active = !1), c) {
                        if ("" == n && r) {
                            var h = Global.configCdn.getRandomChatConf() || Global.configCdn.getDefaultConfig("randomChat");
                            n = h[Global.utils.randomInt(0, h.length - 1)];
                        }
                        n != c.string && (c.string = n, this._resetBubbleSize(n));
                    }
                    if (d && ("" != i ? (console.log("spBtnName :", i), i != d.spriteFrame.name && (d.spriteFrame = Global.spriteAtlas.setSpriteFrame(d, a, i)),
                        d.node.active = !0, u && l && (u.active = !0)) : d.node.active = !1), this.bubble.active || (this.bubble.active = !0),
                    o && "" != o) {
                        var f = {
                            action: o,
                            playMode: s
                        }, p = this.bubble.getComponent(cc.Button);
                        p.clickEvents.splice(0, p.clickEvents.length);
                        var g = new cc.Component.EventHandler();
                        g.target = this.node, g.component = "NPCController", g.handler = "touchEnd", g.customEventData = JSON.stringify(f);
                        var b = new cc.Component.EventHandler();
                        b.target = this.node, b.component = "NPCController", b.handler = "hideNPCBubble",
                            p.clickEvents.push(g), p.clickEvents.push(b);
                    }
                    t >= 0 && this.scheduleOnce(function () {
                        cc.isValid(this.bubble) && this.hideNPCBubble();
                    }.bind(this), t);
                }
            },
            touchEnd: function (e, t) {
                if (console.log("touchEnd event arg:", e, t), t) {
                    var n = JSON.parse(t), o = n.action, i = n.playMode, a = void 0;
                    i && (i == Global.config.playModel.XUEZHAN ? a = Global.config.GAMEID_NORMAL : i == Global.config.playModel.XUELIU ? a = Global.config.GAMEID_NORMAL : i == Global.config.playModel.ERREN ? a = Global.config.GAMEID_ERREN : i == Global.config.playModel.ERRENQUICK && (a = Global.config.GAMEID_ERRENQUICK));
                    var r = {
                        gameId: a,
                        playMode: i
                    }, s = this[o];
                    s && s.call(this, r);
                }
            },
            reset: function () {
                this.bubble && (Global.utils.searchComp(this.bubble, "labStr", cc.Label).node.width = this.labOriginWid || 162,
                    this._resetBubbleSize(), this._isShowingTop && (this._isShowingTop = !1));
            },
            _resetBubbleSize: function () {
                if (this.bubble) {
                    var e = Global.utils.searchComp(this.bubble, "labStr", cc.Label), t = e.node.width + 50;
                    2 == tywx.UserInfo.systemType && (t = e.node.width + 100, e.fontSize = 20), this.bubble.width = t;
                }
            },
            returnRoom: function () {
                var e = Global.config.GAMEID_NORMAL, t = Global.config.playModel.XUELIU;
                Global.tableModel && (Global.tableModel.getGameId() && (e = Global.tableModel.getGameId()),
                Global.tableModel.getPlayMode() && (t = Global.tableModel.getPlayMode()));
                var n = {
                    gameId: e,
                    playMode: t
                };
                this._doQuickStart(n);
            },
            doQuickStart: function (e) {
                console.log("doQuickStart obj：", e), this._doQuickStart(e);
            },
            _doQuickStart: function (e) {
                console.log("_doQuickStart obj：", e);
                var t = e && e.gameId || Global.config.GAMEID_NORMAL, n = {
                    playMode: e && e.playMode || Global.config.playModel.XUELIU,
                    gameId: t,
                    type: "doQuickStart"
                };
                Global.notificationCenter.emit(Global.eventName.MSG_DO_QUICK_START, n), this.hideNPCBubble();
            }
        })
    }